package com.bsdsma.visonManagementSystemapp.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * Base user class containing common properties for all user types
 */
@Data
@MappedSuperclass
public abstract class User implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Column(length = 20)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.AUTO)
    private Long id;

    @Column(name = "account", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String account;

    @Column(name = "password", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String password;

    @Column(name = "head_img_key", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String headImgKey;

    @Column(name = "name", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String name;

    @Column(name = "cellphone_number", columnDefinition = "varchar(200) not null DEFAULT ''")
    private String cellphoneNumber;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date ct;

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date ut;

    @Column(nullable = false)
    private Integer status;

    /**
     * Get the role of this user
     * @return the role as a string
     */
    public abstract String getRole();
}
